package editor;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;

public class DialogUscita extends JDialog implements ActionListener{
	private JLabel label;
	private JButton si;
	private JButton no;
	private JButton annulla;
	private EditorFrame ef;
	
	public DialogUscita(EditorFrame ef){
		this.ef = ef;
		label = new JLabel("Salvare le modifiche apportate?");
		si = new JButton("Si");
		si.addActionListener(this);
		no = new JButton("No");
		no.addActionListener(this);
		annulla = new JButton("Annulla");
		annulla.addActionListener(this);
		this.setLayout(new FlowLayout());
		this.add(label);
		this.add(si);
		this.add(no);
		this.add(annulla);
		this.setTitle("Attenzione");
		this.setSize(220,100);
		this.setLocation(500,300);
		this.setVisible(true);
	}
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == si){
			this.dispose();
			new DialogSalvaLivello(ef);
		}
		if (e.getSource() == no){
				this.dispose();
				ef.dispose();
		}
		if (e.getSource() == annulla){
			this.dispose();
		}
	}

}

